Node Patterns - Networking by Teixeira Pedro
Author:Teixeira, Pedro [Teixeira, Pedro]
Language: eng
Format: epub
Published: 2015-04-07T18:30:00+00:00
Once the server is back up, the client should reconnect successfully and resume operations:
connected DOOR OPEN FOR MORE THAN 1 SECOND, GO CLOSE IT!!! closed now DOOR OPEN FOR MORE THAN 1 SECOND, GO CLOSE IT!!! disconnected disconnected disconnected disconnected disconnected disconnected connected DOOR OPEN FOR MORE THAN 1 SECOND, GO CLOSE IT!!! closed now DOOR OPEN FOR MORE THAN 1 SECOND, GO CLOSE IT!!!
9. Multiplexing Streams
Let’s say now that your refrigerator door sensor server has been proved a success, and that you want to extend it. For instance, you would like to sense the refrigerator temperature and make that data available to the clients connecting to the server.
But there’s a problem: you will need to add more event types and also change the ones that exist: open and close would have to be changed to door open and door close and you will also have to add temperature reading or something similar.
These events should be separated, i.e. transported in different streams, to make the server and client implementations easier and more adaptable to change. We could create different sub-streams on the server -> client stream, one for each device: one for the door sensor, another for the thermometer, and yet another should you choose to add yet another sensor to the refrigerator.
Fortunately this can be easily accomplished by using the mux-demux NPM package: it lets us:
on the server side, multiplex several streams into one stream;
on the client side, do the inverse: demultiplex that stream into separate streams to treat them individually
Download
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.
A Swirl of Ocean by Melissa Sarno(50817)
The Book of Dreams (Saxon Series) by Severin Tim(33306)
Cecilia; Or, Memoirs of an Heiress — Volume 1 by Fanny Burney(32435)
Cecilia; Or, Memoirs of an Heiress — Volume 2 by Fanny Burney(31871)
Cecilia; Or, Memoirs of an Heiress — Volume 3 by Fanny Burney(31856)
Call Me by Your Name by André Aciman(20374)
Eleanor and Park by Rainbow Rowell(15358)
Always and Forever, Lara Jean by Jenny Han(14799)
Norse Mythology by Gaiman Neil(13208)
For the Love of Europe by Rick Steves(13011)
Crooked Kingdom: Book 2 (Six of Crows) by Bardugo Leigh(12219)
Shadow Children #03 - Among the Betrayed by Margaret Peterson Haddix(11839)
Among the Betrayed by Margaret Peterson Haddix(11553)
Twisted Palace by Erin Watt(11085)
Six of Crows by Leigh Bardugo(10053)
They Both Die at the End by Adam Silvera(9721)
P.S. I Still Love You by Jenny Han(9519)
Fangirl by Rainbow Rowell(9097)
Thirteen Reasons Why by Jay Asher(8796)